package com.rjyb.student_management_platform.unit.common;

public class Page {
    Integer currPage=1;//当前页
    int pageSize=20;//每页行数
    int totalRow=0;//总行数
    int totalPage=0;//总页数
    int beginIndex=0;//起始行 (当前页-1) * 每页行数
    public Integer getCurrPage() {
        return currPage;
    }

    public void setCurrPage(Integer currPage) {
        this.currPage = currPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize= pageSize;
    }

    public int getTotalRow() {
        return totalRow;
    }

    public void setTotalRow(int totalRow) {
        this.totalRow = totalRow;
        this.totalRow = totalRow;
        //计算总页数
        totalPage = (totalRow+pageSize-1)/pageSize;
//        int pageSize=5;//每页行数
//        int totalRow=0;//总行数
//        int totalPage=0;//总页数
//        int beginIndex=0;//起始行 (当前页-1) * 每页行数

        //判断当前页
        if(currPage<1){
            this.currPage=1;
        }
        if(currPage>totalPage&&totalPage!=0){
            this.currPage=totalPage;
        }
        //计算起始行
        this.beginIndex=(this.currPage-1)*this.pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public void setBeginIndex(int beginIndex) {
        this.beginIndex = beginIndex;
    }
}
